var BaseController = new require("./basecontroller");

function Controller(){
	BaseController.call(this);
}

Controller.prototype = Object.create (BaseController.prototype);
Controller.prototype.constructor = Controller;
Controller.prototype.FORM_ENTRIES = Array("name", "status");
Controller.prototype.SEARCH_ENTRIES = Array("name", "date_added");
Controller.prototype.TABLE = "user_group"; //table for this controller
Controller.prototype.CONTROLLER = "user-group"; //controllername
Controller.prototype.PAGE = "user_group";
Controller.prototype.FORM_VIEW = "backend/user-group/user-group-form";
Controller.prototype.LIST_VIEW = "backend/user-group/user-group-list";

Controller.prototype.postInsert = function(req, res, data, insertedRow){
	console.log("INSERTED! = " + JSON.stringify(insertedRow));
	var connection = this.getConnection();
	//insertedId
	var initialData = {archived : 1, user_group_id : insertedRow.insertId};
    var query = connection.query("insert into user_group_permission set ? ",[initialData], function(err, row)
	        {
	          if (err){
	              console.log("Error updating : %s ",err );
	          }else{
	        	  console.log("SUCCESS!! " + query.sql)
	          }
	        });
	
	return data;
}

Controller.prototype.RECORDS_PER_PAGE = 3;


module.exports = new Controller();

/*
ADDITIONAL CODES
override methods
*/
/*UserController.prototype.preInsert = function(req, res, data){
	return data;
}*/